﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ServisniList.Core;

namespace ServisniList
{
    public partial class ServisniListIsporuka : Form
    {

        private DataModelDataContext context = null;
        private Core.List trenutniList = null;

        public ServisniListIsporuka(DataModelDataContext ulazniContext, Core.List inputLList)
        {
            InitializeComponent();
            context = ulazniContext;
            trenutniList = inputLList;
            lblIsporuciteljVrijednost.Text = Rukovatelji.Korisnici.GetInstance().GeneriajPrikazKorisnika();
            lblDatumIsporukeVrijednost.Text = DateTime.Now.ToShortDateString();

            rbPnp.Checked = trenutniList.IsporukaUPnp;
            rbKodKorisnika.Checked = !trenutniList.IsporukaUPnp;

        }

        private void btnSpremi_Click(object sender, EventArgs e)
        {
            trenutniList.DatumIsporuke = DateTime.Now;
            trenutniList.IsporuciteljID = Rukovatelji.Korisnici.GetInstance().TreutnoUlogiraniDjelatnik.ID;
            trenutniList.IsporukaUPnp = rbPnp.Checked;
            context.SubmitChanges();
            this.Close();
        }

        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (e.KeyCode == Keys.Escape)
                this.Close();
        }
    }
}
